package Classes.Components
{
	import Classes.Entity;
	import Classes.World;
	
	import flash.events.EventDispatcher;
	import flash.utils.getQualifiedClassName;

	public class BaseComponent extends EventDispatcher implements IComponent
	{
		private var m_destroyFlag:Boolean = false;
		protected var m_entity:Entity;

		public function BaseComponent(entity:Entity)
		{
			m_entity = entity;
		}
		
		public function getWorld():World{
			return m_entity.getWorld();
		}		
		
		public function getEntity():Entity{
			return m_entity;
		}
		
		public function enableDestroy():void{
			m_destroyFlag = true;
		} 
		
		public function canDestroy():Boolean{
			return m_destroyFlag;
		}

		public function update(delta:int):void{
			
		}
		
		public function getType():String{
			return getQualifiedClassName(this);
		}		
		
		public function destroy():void{
			Main.componentManager.removeComponent(this);	
		}
	
	}
}